<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>添加咨询</title>
    <?php require 'templates/common/head.html'; ?>
</head>
<body>


<div class="container-fluid">
    <?php require 'templates/common/nav.html'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">图文消息</h3></div>
        <div class="panel-group"  id="accordion" role="tablist" aria-multiselectable="true">
            <div class="panel panel-default">
                <div class="panel-heading" style="background-color:#d5d5d5">
                    <div class="row" >
                        <div class="col-xs-1 col-sm-1" style="text-align:center">排序</div>
                        <div class="col-xs-3 col-sm-3" style="text-align:center">标题</div>
                        <div class="col-xs-2 col-sm-2" style="text-align:center">图片预览</div>
                        <div class="col-xs-2 col-sm-2" style="text-align:center">描述</div>
                        <div class="col-xs-2 col-sm-2" style="text-align:center">添加时间</div>
                        <div class="col-xs-2 col-sm-2" style="text-align:center" >操作</div>
                    </div>
                </div>
            </div>
            <?php foreach($details as $v):?>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row" >
                            <div class="col-xs-1 col-sm-1" style="text-align:center">
                                <?=$v['排序']?>&nbsp;
                            </div>
                            <div class="col-xs-3 col-sm-3" style="text-align:center">
                                <a href="<?=$v['文章url']?>" target="_blank" ><?=$v['标题']?></a>
                            </div>
                            <div class="col-xs-2 col-sm-2">
                                <img src="<?=$v['图片url']?>" style="width:200px;" />
                            </div>
                            <div class="col-xs-2 col-sm-2" style="text-align:center">
                                <?=$v['description']?>
                            </div>
                            <div class="col-xs-2 col-sm-2" style="text-align:center">
                                <?=$v['添加时间']?>
                            </div>
                            <div class="col-xs-2 col-sm-2" style="text-align:center">

                                <button onclick="bianji('<?=$v['id']?>')" class=" btn btn-primary">编辑</button>&nbsp;
                                <a href="index.php?m=push_information&a=del&detail_id=<?=$v['id']?>&info_id=<?=$_GET['id']?>" onclick=" javascript:  return  confirm('是否确认删除?')"><button  class=" btn btn-primary">删除</button>&nbsp;</a>
                            </div>
                        </div>
                    </div>
                </div>
                <?php  endforeach;?>
        </div>
        <div style="padding: 30px 30px 10px;" >
            <div class="panel-heading text-center"><h3 class="panel-title">添加图文消息</h3></div>
            <form action="index.php?m=push_information&a=add_image_message" method="post" class="bs-example bs-example-form" role="form" id="form1" enctype="multipart/form-data">
                <div class="input-group">
                    <span class="input-group-addon">标题</span>
                    <input type="text" class="form-control" name="title">
                    <input type="hidden" name="info_id" value="<?=$_GET['id']?>">
                </div>
                <br>
                <div class="input-group">
                    <span class="input-group-addon">图片url</span>
                    <input type="file"  name="pic" >
                </div>
                <br>
                <div class="input-group">
                    <span class="input-group-addon">文章url</span>
                    <input type="text" class="form-control" name="text_url">
                </div>
                <br>
                <div class="input-group">
                    <span class="input-group-addon">描述</span>
                    <input type="text" class="form-control" name="description">
                </div>
                <br>
                <div class="input-group">
                    <span class="input-group-addon">排序</span>
                    <input type="text" class="form-control" name="sort">
                </div>
                <br>
                <div class="input-group">
                    <input type="submit" class="form-control btn btn-primary" value="提交">
                </div>
            </form>

        </div>
    </div>
</div>

<div style="position: fixed;left:100px;top:100px;width:80%;height: 70%; background: #ccc;display: none;z-index: 3" id="xianshi">
    <div style="padding: 30px 30px 10px;" >
        <form action="index.php?m=push_information&a=add_image_message" method="post" class="bs-example bs-example-form" role="form" id="form2" enctype="multipart/form-data">
            <div class="input-group">
                <span class="input-group-addon">标题</span>
                <input type="text" class="form-control" name="title">
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">咨询类别</span>

                <select class="form-control" id="news_type" name="news_type">
                    <?php foreach($news_type as $k=>$v ):?>
                    <option value="<?=$k+1?>"><?=$v?></option>
                    <?php endforeach; ?>

                </select>
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">修改图片url</span>
                <input type="file"  name="pic" >
                <input type="hidden"  name="image_url" >
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">原图片url</span>
                <input type="text" class="form-control" name="url" disabled >
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">文章url</span>
                <input type="text" class="form-control" name="text_url">
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">描述</span>
                <input type="text" class="form-control" name="description">
            </div>
            <br>
            <div class="input-group">
                <span class="input-group-addon">排序</span>
                <input type="text" class="form-control" name="sort">
                <input type="hidden" name="detail_id">
                <input type="hidden" name="info_id" value="<?=$_GET['id']?>">
            </div>
            <br>
            <div>
                <input type="submit" class="btn btn-primary" value="提交">
                 <input type="button" onclick="quxiao()" class=" btn btn-primary" value="取消">
            </div>
        </form>
    </div>
</div>

<?php require 'templates/common/foot.html'; ?>

</body>
</html>
<script language="JavaScript">
    function bianji(detailId){
        $.post('index.php?m=push_information&a=show_image_message',{'detail_id':detailId},function(data){
            var obj = eval('(' + data + ')');
            $("#xianshi").show();
            $("#form2").find("input[name='title']").val(obj['标题']);
            $("#form2").find("input[name='image_url']").val(obj['图片url']);
            $("#form2").find("input[name='url']").val(obj['图片url']);
            $("#form2").find("input[name='text_url']").val(obj['文章url']);
            $("#form2").find("input[name='description']").val(obj['description']);
            $("#form2").find("input[name='sort']").val(obj['排序']);
            $("#form2").find("input[name='detail_id']").val(obj['id']);
            //不懂什么意思
            if(obj['news_type']==2)
            {
                $("#news_type").children().attr("selected","selected");
            }

        });
    }
    function quxiao(){
        $("#xianshi").hide();
    }

</script>
